package ru.nosport.matrixaria.modules.user.rexample.server;

import java.io.Externalizable;
import java.io.ObjectOutput;
import java.io.IOException;
import java.io.ObjectInput;

/**
 * User: Victor Fabrichenko
 * Date: 24.12.2008
 * Time: 14:28:21
 */
public class DataContainer  implements Externalizable {
	private static final long serialVersionUID = -2045076520575570882L;

	private int fieldInt;
	private String fieldString;
	private boolean fieldBoolean;
	private long fieldLong;
	private float fieldFloat;
	private double fieldDouble;

	public DataContainer() {
		this(0, true, 0, 0, 0, "");
	}

	public DataContainer
			(int fieldInt,
						 boolean fieldBoolean,
						 long fieldLong,
						 float fieldFloat,
						 double fieldDouble,
						 String fieldString) {
		this.fieldInt = fieldInt;
		this.fieldLong = fieldLong;
		this.fieldBoolean = fieldBoolean;
		this.fieldFloat = fieldFloat;
		this.fieldDouble = fieldDouble;
		this.fieldString = fieldString;
	}

	public int getFieldInt() {
		return fieldInt;
	}

	public boolean getFieldBoolean() {
		return fieldBoolean;
	}

	public long getFieldLong() {
		return fieldLong;
	}

	public float getFieldFloat() {
		return fieldFloat;
	}

	public double getFieldDouble() {
		return fieldDouble;
	}

	public String getFieldString() {
		return fieldString;
	}


	public void writeExternal(ObjectOutput out) throws IOException {
		out.writeInt(fieldInt);
		out.writeBoolean(fieldBoolean);
		out.writeLong(fieldLong);
		out.writeFloat(fieldFloat);
		out.writeDouble(fieldDouble);
		out.writeUTF(fieldString);
	}

	public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
		fieldInt = in.readInt();
		fieldBoolean = in.readBoolean();
		fieldLong = in.readLong();
		fieldFloat = in.readFloat();
		fieldDouble = in.readDouble();
		fieldString = in.readUTF();
	}

	public String toString() {
		return ""+
				this.fieldBoolean+
				this.fieldDouble+
				this.fieldFloat+
				this.fieldInt+
				this.fieldLong+
				this.fieldString;
	}
}
